import pandas as pd
import numpy as np
import math
import re
import requests
from pandas.io.json import json_normalize
import geopandas as gpd
from sklearn.cluster import KMeans
from shapely.geometry import Polygon, LineString, Point
from shapely.ops import transform
# Matplotlib and associated plotting modules
import matplotlib.pyplot as plt
import matplotlib.cm as cm
import matplotlib.colors as colors
#!conda install -c conda-forge folium=0.5.0 geopandas=0.4.1 --yes
import folium # map rendering library
Create a map of Edinburgh, split into its natural neighbourhoods. https://python-visualization.github.io/folium/quickstart.html This is a link for my use later when I want to colour code the map based on similarity.
#url = ("https://opendata.arcgis.com/datasets/9961be54aa5649aebfb5f2cde53fa432_27.geojson") #dataset for natural neighbourhoods in Edinburgh from Edinburgh City Council
#neighbourhoods = gpd.read_file(url)
#print(neighbourhoods.head())
url = (
"https://opendata.arcgis.com/datasets/9961be54aa5649aebfb5f2cde53fa432_27.geojson" #dataset for natural neighbourhoods in Edinburgh from Edinburgh City Council
)
natural_neighbourhoods = f"{url}"
m = folium.Map(
location=[55.9533, -3.1883],
tiles="cartodbpositron",
zoom_start=13,
)
shapes = folium.GeoJson(natural_neighbourhoods, name="geojson")
shapes.add_to(m)
folium.LayerControl().add_to(m)
m
https://geopandas.readthedocs.io/en/latest/gallery/polygon_plotting_with_folium.html example I used to help with the next cell.
path = "https://opendata.arcgis.com/datasets/9961be54aa5649aebfb5f2cde53fa432_27.geojson"
df = gpd.read_file(path)
m = folium.Map(location=[55.9533, -3.1883], zoom_start=10, tiles='CartoDB positron')
for _, r in df.iterrows():
sim_geo = gpd.GeoSeries(r['geometry'])
geo_j = sim_geo.to_json()
geo_j = folium.GeoJson(data=geo_j,
style_function=lambda x: {'fillColor': 'orange'})
folium.Popup(r['NATURALCOM']).add_to(geo_j)
geo_j.add_to(m)
df = df.to_crs(epsg=2163) #set to a projected crs for centroid calculation accuracy.
df['centroids']=df.centroid.to_crs(epsg=4326)
df['lat'] = df['centroids'].y
df['lon'] = df['centroids'].x
df = df.to_crs(epsg=4326)
for _, r in df.iterrows():
yo = folium.Marker(location=[r['lat'], r['lon']], popup='Name: {}'.format(r['NATURALCOM']))
yo.add_to(m)
m
The following must be entered to use the foursquare API. The results of this call have been saved in a file for future use to avoid repeated API calls.
CLIENT_ID = ""
CLIENT_SECRET = ""
VERSION = ''
LIMIT = 100
def getNearbyVenues(names, latitudes, longitudes, area):
venues_list=[]
for name, lat, lng, area2 in zip(names, latitudes, longitudes, area):
radius = 2*math.sqrt(area2/3) #factor of two to account for weirdly shaped areas. This makes a circle with twice the radius of the circle of the same area as the shape.
# create the API request URL
url = 'https://api.foursquare.com/v2/venues/search?&client_id={}&client_secret={}&v={}&ll={},{}&radius={}&limit={}&categoryId=4d4b7105d754a06374d81259'.format(
CLIENT_ID,
CLIENT_SECRET,
VERSION,
lat,
lng,
radius,
LIMIT)
# make the GET request
results = requests.get(url).json()["response"]['venues']
#print(results)
# return only relevant information for each nearby venue
venues_list.append([[name, lat, lng, v['id'],v['name'], v['location']['lat'], v['location']['lng'], v['categories'][0]['name']] for v in results])
nearby_venues = pd.DataFrame([item for venue_list in venues_list for item in venue_list])
nearby_venues.columns = ['Neighbourhood',
'Neighbourhood Latitude',
'Neighbourhood Longitude',
'Venue ID',
'Venue',
'Venue Latitude',
'Venue Longitude',
'Venue Category']
return(nearby_venues)
edinburgh_venues = getNearbyVenues(names=df['NATURALCOM'],
latitudes=df['lat'],
longitudes=df['lon'],
area = df['Shapearea']
)
edinburgh_venues.head()
| Neighbourhood | Neighbourhood Latitude | Neighbourhood Longitude | Venue ID | Venue | Venue Latitude | Venue Longitude | Venue Category | |
|---|---|---|---|---|---|---|---|---|
| 0 | Brunstane/Gilberstoun | 55.940545 | -3.09246 | 4c417b3aaf052d7fd7707d79 | Cuddie Brae | 55.934582 | -3.094717 | Restaurant |
| 1 | Brunstane/Gilberstoun | 55.940545 | -3.09246 | 54b97471498e26d1ad55ee73 | Bar Zest | 55.944542 | -3.096077 | Gastropub |
| 2 | Brunstane/Gilberstoun | 55.940545 | -3.09246 | 51483ee8e4b06af4b55605bb | kingsminor bistrot | 55.945272 | -3.096003 | Breakfast Spot |
| 3 | Brunstane/Gilberstoun | 55.940545 | -3.09246 | 4c4c67949e6dbe9a15c9700d | Porto Restaurant | 55.946333 | -3.084878 | Fast Food Restaurant |
| 4 | Brunstane/Gilberstoun | 55.940545 | -3.09246 | 4bd0525e046076b02fb36f71 | Costa Coffee | 55.933625 | -3.105237 | Coffee Shop |
The DataFrame is transformed into a GeoDataFrame and then is cleaned up by removing any venues that are not in the correct neighbourhood, as up until this point neighbourhoods have been assumed to be a large circle focused on their centres, for the purposes of the API call.
edinburgh_venues_geo = gpd.GeoDataFrame(edinburgh_venues, geometry = gpd.points_from_xy(edinburgh_venues["Venue Longitude"],edinburgh_venues["Venue Latitude"]))
edinburgh_venues_geo.head()
| Neighbourhood | Neighbourhood Latitude | Neighbourhood Longitude | Venue ID | Venue | Venue Latitude | Venue Longitude | Venue Category | geometry | |
|---|---|---|---|---|---|---|---|---|---|
| 0 | Brunstane/Gilberstoun | 55.940545 | -3.09246 | 4c417b3aaf052d7fd7707d79 | Cuddie Brae | 55.934582 | -3.094717 | Restaurant | POINT (-3.09472 55.93458) |
| 1 | Brunstane/Gilberstoun | 55.940545 | -3.09246 | 54b97471498e26d1ad55ee73 | Bar Zest | 55.944542 | -3.096077 | Gastropub | POINT (-3.09608 55.94454) |
| 2 | Brunstane/Gilberstoun | 55.940545 | -3.09246 | 51483ee8e4b06af4b55605bb | kingsminor bistrot | 55.945272 | -3.096003 | Breakfast Spot | POINT (-3.09600 55.94527) |
| 3 | Brunstane/Gilberstoun | 55.940545 | -3.09246 | 4c4c67949e6dbe9a15c9700d | Porto Restaurant | 55.946333 | -3.084878 | Fast Food Restaurant | POINT (-3.08488 55.94633) |
| 4 | Brunstane/Gilberstoun | 55.940545 | -3.09246 | 4bd0525e046076b02fb36f71 | Costa Coffee | 55.933625 | -3.105237 | Coffee Shop | POINT (-3.10524 55.93363) |
Define a function to find which neighbourhood the venue is really in.
def which_neighbourhood(test_point):
for i in range(154):
if df["geometry"].contains(test_point)[i] == True:
return df["NATURALCOM"][i]
Run the function for every row of the data frame and drop any rows where the neighbourhood label is not accurate in terms of the natural neighbourhood boundary.
print(edinburgh_venues_geo.shape)
for ind in edinburgh_venues_geo.index:
location = edinburgh_venues_geo['geometry'][ind]
if edinburgh_venues_geo['Neighbourhood'][ind] != which_neighbourhood(location):
edinburgh_venues_geo.drop(ind, inplace = True)
edinburgh_venues_geo.reset_index(inplace = True)
edinburgh_venues_geo.drop(["index"], axis=1, inplace = True)
print(edinburgh_venues_geo.shape)
edinburgh_venues_geo.head()
(4089, 9) (835, 9)
| Neighbourhood | Neighbourhood Latitude | Neighbourhood Longitude | Venue ID | Venue | Venue Latitude | Venue Longitude | Venue Category | geometry | |
|---|---|---|---|---|---|---|---|---|---|
| 0 | Brunstane/Gilberstoun | 55.940545 | -3.09246 | 54b97471498e26d1ad55ee73 | Bar Zest | 55.944542 | -3.096077 | Gastropub | POINT (-3.09608 55.94454) |
| 1 | Brunstane/Gilberstoun | 55.940545 | -3.09246 | 4e0cd9d27d8bfe35bbc5d23d | eh15 Restaurant & Bar | 55.943865 | -3.098488 | Diner | POINT (-3.09849 55.94386) |
| 2 | Brunstane/Gilberstoun | 55.940545 | -3.09246 | 4e0b733ab0fbc7fb0be0d383 | Options | 55.944675 | -3.096049 | Restaurant | POINT (-3.09605 55.94467) |
| 3 | Brunstane/Gilberstoun | 55.940545 | -3.09246 | 4cdd6bd114119eb02a35ed33 | Burger King | 55.942378 | -3.101092 | Fast Food Restaurant | POINT (-3.10109 55.94238) |
| 4 | Brunstane/Gilberstoun | 55.940545 | -3.09246 | 5ecfd256fadd010008813b03 | Costa Coffee | 55.941996 | -3.101744 | Coffee Shop | POINT (-3.10174 55.94200) |
Map all venues that are still being used.
m = folium.Map(location=[55.9533, -3.1883], zoom_start=10, tiles='CartoDB positron')
for _, r in df.iterrows():
sim_geo = gpd.GeoSeries(r['geometry'])
geo_j = sim_geo.to_json()
geo_j = folium.GeoJson(data=geo_j,
style_function=lambda x: {'fillColor': 'orange'})
folium.Popup(r['NATURALCOM']).add_to(geo_j)
geo_j.add_to(m)
for _, r in edinburgh_venues_geo.iterrows():
yo = folium.Marker(location=[r['Venue Latitude'], r['Venue Longitude']], popup='name: {}'.format(r['Venue']))
yo.add_to(m)
m
Now to add a column with additional data about each venue.
#returns the price tier and likes count of the venues.
def furtherDetails(venue_id):
url = 'https://api.foursquare.com/v2/venues/{}?&client_id={}&client_secret={}&v={}'.format(venue_id,CLIENT_ID, CLIENT_SECRET,VERSION)
results = requests.get(url).json()
try:
return results['response']['venue']['attributes']['groups'][0]['items'][0]['priceTier'], results['response']['venue']['likes']['count']
except:
return "missing price tier", "missing likes" #if the data is strangely formatted for this venue.
edinburgh_venues_geo['price tier','likes'] = edinburgh_venues_geo['Venue ID'].apply(furtherDetails) #apply the above function
edinburgh_venues_geo.head()
| Neighbourhood | Neighbourhood Latitude | Neighbourhood Longitude | Venue ID | Venue | Venue Latitude | Venue Longitude | Venue Category | geometry | (price tier, likes) | |
|---|---|---|---|---|---|---|---|---|---|---|
| 0 | Brunstane/Gilberstoun | 55.940545 | -3.09246 | 54b97471498e26d1ad55ee73 | Bar Zest | 55.944542 | -3.096077 | Gastropub | POINT (-3.09608 55.94454) | (3, 0) |
| 1 | Brunstane/Gilberstoun | 55.940545 | -3.09246 | 4e0cd9d27d8bfe35bbc5d23d | eh15 Restaurant & Bar | 55.943865 | -3.098488 | Diner | POINT (-3.09849 55.94386) | (1, 3) |
| 2 | Brunstane/Gilberstoun | 55.940545 | -3.09246 | 4e0b733ab0fbc7fb0be0d383 | Options | 55.944675 | -3.096049 | Restaurant | POINT (-3.09605 55.94467) | (2, 0) |
| 3 | Brunstane/Gilberstoun | 55.940545 | -3.09246 | 4cdd6bd114119eb02a35ed33 | Burger King | 55.942378 | -3.101092 | Fast Food Restaurant | POINT (-3.10109 55.94238) | (1, 0) |
| 4 | Brunstane/Gilberstoun | 55.940545 | -3.09246 | 5ecfd256fadd010008813b03 | Costa Coffee | 55.941996 | -3.101744 | Coffee Shop | POINT (-3.10174 55.94200) | (1, 0) |
edinburgh_venues_geo.columns
missing = edinburgh_venues_geo[edinburgh_venues_geo[('price tier', 'likes')] == ('missing price tier', 'missing likes')]
print(missing.shape)
print(edinburgh_venues_geo.shape)
(46, 10) (835, 10)
The number of rows without price tier and likes is relatively small. Need to check if they are evenly or unevenly distributed.
print(missing['Neighbourhood'].value_counts().head())
print(missing['Neighbourhood'].value_counts().tail())
Portobello 5 Tollcross 3 Newington 3 Hillside/Easter Rd 2 South Gyle/Edinburgh Park 2 Name: Neighbourhood, dtype: int64 Braids 1 Calton Hill 1 Gracemount 1 South Queensferry/Dalmeny 1 Corstorphine 1 Name: Neighbourhood, dtype: int64
The rows with missing data are pretty much evenly distributed between the neighbourhoods and so will be dropped from the dataframe.
indexNames = edinburgh_venues_geo[edinburgh_venues_geo[('price tier', 'likes')] == ('missing price tier', 'missing likes')].index
edinburgh_venues_geo.drop(indexNames , inplace=True)
edinburgh_venues_geo.head()
| Neighbourhood | Neighbourhood Latitude | Neighbourhood Longitude | Venue ID | Venue | Venue Latitude | Venue Longitude | Venue Category | geometry | (price tier, likes) | |
|---|---|---|---|---|---|---|---|---|---|---|
| 0 | Brunstane/Gilberstoun | 55.940545 | -3.09246 | 54b97471498e26d1ad55ee73 | Bar Zest | 55.944542 | -3.096077 | Gastropub | POINT (-3.09608 55.94454) | (3, 0) |
| 1 | Brunstane/Gilberstoun | 55.940545 | -3.09246 | 4e0cd9d27d8bfe35bbc5d23d | eh15 Restaurant & Bar | 55.943865 | -3.098488 | Diner | POINT (-3.09849 55.94386) | (1, 3) |
| 2 | Brunstane/Gilberstoun | 55.940545 | -3.09246 | 4e0b733ab0fbc7fb0be0d383 | Options | 55.944675 | -3.096049 | Restaurant | POINT (-3.09605 55.94467) | (2, 0) |
| 3 | Brunstane/Gilberstoun | 55.940545 | -3.09246 | 4cdd6bd114119eb02a35ed33 | Burger King | 55.942378 | -3.101092 | Fast Food Restaurant | POINT (-3.10109 55.94238) | (1, 0) |
| 4 | Brunstane/Gilberstoun | 55.940545 | -3.09246 | 5ecfd256fadd010008813b03 | Costa Coffee | 55.941996 | -3.101744 | Coffee Shop | POINT (-3.10174 55.94200) | (1, 0) |
Check the above has done the expected operation:
edinburgh_venues_geo.columns
oopsy = edinburgh_venues_geo[edinburgh_venues_geo[('price tier', 'likes')] == ('missing price tier', 'missing likes')]
print(oopsy.shape)
print(edinburgh_venues_geo.shape)
(0, 10) (789, 10)
The following splits the price tier and likes column into separate columns.
edinburgh_venues_geo[('price tier','likes')]=edinburgh_venues_geo[('price tier','likes')].astype('string')
re.findall("[0-9]*",edinburgh_venues_geo[('price tier','likes')][0])
#print(re.findall("[0-9]+","(12, 0)"))
def price_extractor(text):
numberList = re.findall("[0-9]+",text)
return numberList[0]
def likes_extractor(text):
numberList = re.findall("[0-9]+",text)
return numberList[0]
edinburgh_venues_geo['price tier'] = edinburgh_venues_geo[('price tier','likes')].apply(lambda x: price_extractor(x))
edinburgh_venues_geo['likes'] = edinburgh_venues_geo[('price tier','likes')].apply(lambda x: likes_extractor(x))
edinburgh_venues_geo.head()
| Neighbourhood | Neighbourhood Latitude | Neighbourhood Longitude | Venue ID | Venue | Venue Latitude | Venue Longitude | Venue Category | geometry | (price tier, likes) | price tier | likes | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | Brunstane/Gilberstoun | 55.940545 | -3.09246 | 54b97471498e26d1ad55ee73 | Bar Zest | 55.944542 | -3.096077 | Gastropub | POINT (-3.09608 55.94454) | (3, 0) | 3 | 3 |
| 1 | Brunstane/Gilberstoun | 55.940545 | -3.09246 | 4e0cd9d27d8bfe35bbc5d23d | eh15 Restaurant & Bar | 55.943865 | -3.098488 | Diner | POINT (-3.09849 55.94386) | (1, 3) | 1 | 1 |
| 2 | Brunstane/Gilberstoun | 55.940545 | -3.09246 | 4e0b733ab0fbc7fb0be0d383 | Options | 55.944675 | -3.096049 | Restaurant | POINT (-3.09605 55.94467) | (2, 0) | 2 | 2 |
| 3 | Brunstane/Gilberstoun | 55.940545 | -3.09246 | 4cdd6bd114119eb02a35ed33 | Burger King | 55.942378 | -3.101092 | Fast Food Restaurant | POINT (-3.10109 55.94238) | (1, 0) | 1 | 1 |
| 4 | Brunstane/Gilberstoun | 55.940545 | -3.09246 | 5ecfd256fadd010008813b03 | Costa Coffee | 55.941996 | -3.101744 | Coffee Shop | POINT (-3.10174 55.94200) | (1, 0) | 1 | 1 |
Save data to avoid uneccessary calls to the API.
edinburgh_venues_geo.to_csv('') #Fill in with a backup location to avoid unecessary API calls.
Start here to avoid calls to API
edinburgh_venues_geo = pd.read_csv('')
edinburgh_venues_geo.shape
(789, 13)
Remove neighbourhoods with less than 5 venues from the analysis.
list_to_discard = edinburgh_venues_geo.value_counts('Neighbourhood')[edinburgh_venues_geo.value_counts('Neighbourhood')<5].index.tolist()
print(list_to_discard)
edinburgh_venues_geo.set_index('Neighbourhood', inplace=True)
edinburgh_venues_geo.drop(list_to_discard, axis = 0, inplace=True)
edinburgh_venues_geo.reset_index(inplace=True)
print(edinburgh_venues_geo.shape)
edinburgh_venues_geo.head()
['Comiston', 'Calders', 'Viewforth', 'Merchiston and Myreside', 'Leith Links', 'Liberton', 'Bellevue/Broughton', 'North Sighthill', 'Craiglockhart', 'The Inch', 'Juniper Green', 'Cramond', 'Balerno', 'Wester Hailes', 'Polwarth', 'Pilton/Royston', 'Redhall/Inglis Green', 'Parkhead', 'Restalrig', 'Calton Hill', 'Fernieside/Ferniehill', 'Mortonhall', 'Fountainbridge', 'Corstorphine/Craigmount', 'Stenhouse/Saughton', 'Dumbiedykes', 'Kirkliston', 'Longstone', 'Carrick Knowe', 'Lauriston/Quartermile', 'Fairmilehead/Swanston', 'Gilmerton', 'Crewe Toll', 'Sighthill', 'Craigentinny', 'Churchill and Greenhill', 'Broomhouse', 'Magdalene', 'Colinton/Bonaly', 'Wester Coates', 'Silverknowes', 'Southhouse', 'Kingsknowe', 'Seafield', 'Ravelston/Murrayfield', 'Ratho', 'Northfield', 'Newcraighall', 'Marionville', 'Lochend', 'Baberton', 'East Craigs', 'Dumbryden', 'Duddingston/The Durhams', 'Corstorphine/North Gyle', 'Burdiehouse', 'Braids', 'Boswall/Wardie', 'Willowbrae'] (650, 13)
| Neighbourhood | Unnamed: 0 | Neighbourhood Latitude | Neighbourhood Longitude | Venue ID | Venue | Venue Latitude | Venue Longitude | Venue Category | geometry | ('price tier', 'likes') | price tier | likes | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | Brunstane/Gilberstoun | 0 | 55.940545 | -3.09246 | 54b97471498e26d1ad55ee73 | Bar Zest | 55.944542 | -3.096077 | Gastropub | POINT (-3.0960774421691895 55.944541931152344) | (3, 0) | 3 | 3 |
| 1 | Brunstane/Gilberstoun | 1 | 55.940545 | -3.09246 | 4e0cd9d27d8bfe35bbc5d23d | eh15 Restaurant & Bar | 55.943865 | -3.098488 | Diner | POINT (-3.0984878540039062 55.943864908788534) | (1, 3) | 1 | 1 |
| 2 | Brunstane/Gilberstoun | 2 | 55.940545 | -3.09246 | 4e0b733ab0fbc7fb0be0d383 | Options | 55.944675 | -3.096049 | Restaurant | POINT (-3.096049 55.944675) | (2, 0) | 2 | 2 |
| 3 | Brunstane/Gilberstoun | 3 | 55.940545 | -3.09246 | 4cdd6bd114119eb02a35ed33 | Burger King | 55.942378 | -3.101092 | Fast Food Restaurant | POINT (-3.1010922900120104 55.942377593318554) | (1, 0) | 1 | 1 |
| 4 | Brunstane/Gilberstoun | 4 | 55.940545 | -3.09246 | 5ecfd256fadd010008813b03 | Costa Coffee | 55.941996 | -3.101744 | Coffee Shop | POINT (-3.101744055747986 55.94199631334696) | (1, 0) | 1 | 1 |
edin_onehot = pd.get_dummies(edinburgh_venues_geo['Venue Category'])
edin_onehot['likes'] = edinburgh_venues_geo['likes']
edin_onehot['price tier'] = edinburgh_venues_geo['price tier']
edin_onehot['Neighbourhood'] = edinburgh_venues_geo['Neighbourhood']
# shift column 'Name' to first position
first_column = edin_onehot.pop('Neighbourhood')
second_column = edin_onehot.pop('likes')
third_column = edin_onehot.pop('price tier')
# insert column using insert(position,column_name,
# first_column) function
edin_onehot.insert(0, 'Neighbourhood', first_column)
edin_onehot.insert(1, 'likes', second_column)
edin_onehot.insert(2, 'price tier', third_column)
edin_onehot['price tier']=edin_onehot['price tier']/edin_onehot['price tier'].max()
edin_onehot.head()
| Neighbourhood | likes | price tier | African Restaurant | American Restaurant | Asian Restaurant | BBQ Joint | Bagel Shop | Bakery | Bar | ... | Spanish Restaurant | Steakhouse | Sushi Restaurant | Taco Place | Tapas Restaurant | Tea Room | Thai Restaurant | Turkish Restaurant | Vegetarian / Vegan Restaurant | Vietnamese Restaurant | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | Brunstane/Gilberstoun | 3 | 0.75 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 1 | Brunstane/Gilberstoun | 1 | 0.25 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 2 | Brunstane/Gilberstoun | 2 | 0.50 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 3 | Brunstane/Gilberstoun | 1 | 0.25 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 4 | Brunstane/Gilberstoun | 1 | 0.25 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
5 rows × 61 columns
edin_onehot.to_csv('') # Backup opportunity following further API calls.
Sum over each type of venue and only keep venues with more than 5 occurences.
summed = edin_onehot.sum().drop(["Neighbourhood","likes", "price tier"])
list_to_use = ["Neighbourhood", "price tier"]
for i in range(len(summed)):
if summed[i]>3:
list_to_use.append(edin_onehot.columns[i+3])
list_to_use
edin_grouped = edin_onehot[list_to_use]
Take mean of each column for each neighbourhood.
edin_grouped = edin_grouped.groupby('Neighbourhood', as_index=False).mean()
#print(edin_grouped.head())
Add columns giving the top 3 venues for each Neighbourhood.
num_top_venues = 3
def return_most_common_venues(row, num_top_venues):
row_categories = row.iloc[2:]
row_categories_sorted = row_categories.sort_values(ascending=False)
print(row_categories_sorted)
data_to_return = [row_categories_sorted.index.values[0]]
if row_categories_sorted[1] != 0:
data_to_return.append(row_categories_sorted.index.values[1])
else:
data_to_return.append('....')
if row_categories_sorted[2] != 0:
data_to_return.append(row_categories_sorted.index.values[2])
else:
data_to_return.append('....')
print(data_to_return)
return data_to_return
indicators = ['st', 'nd', 'rd']
# create columns according to number of top venues
columns = ['Neighbourhood']
for ind in np.arange(num_top_venues):
try:
columns.append('{}{} Most Common Venue'.format(ind+1, indicators[ind]))
except:
columns.append('{}th Most Common Venue'.format(ind+1))
# create a new dataframe
neighbourhoods_venues_sorted = pd.DataFrame(columns=columns)
neighbourhoods_venues_sorted['Neighbourhood'] = edin_grouped['Neighbourhood']
for ind in np.arange(edin_grouped.shape[0]):
neighbourhoods_venues_sorted.iloc[ind, 1:] = return_most_common_venues(edin_grouped.iloc[ind, :], num_top_venues)
neighbourhoods_venues_sorted.head()
Chinese Restaurant 0.333333 Café 0.166667 Fast Food Restaurant 0.166667 Pizza Place 0.166667 Vietnamese Restaurant 0.083333 Dessert Shop 0.083333 Italian Restaurant 0.0 Turkish Restaurant 0.0 Thai Restaurant 0.0 Steakhouse 0.0 Snack Place 0.0 Seafood Restaurant 0.0 Sandwich Place 0.0 Restaurant 0.0 Pub 0.0 Bakery 0.0 Indian Restaurant 0.0 Ice Cream Shop 0.0 Bar 0.0 Food Truck 0.0 Fish & Chips Shop 0.0 Diner 0.0 Deli / Bodega 0.0 Coffee Shop 0.0 Burger Joint 0.0 Breakfast Spot 0.0 Gastropub 0.0 Name: 0, dtype: object ['Chinese Restaurant', 'Café', 'Fast Food Restaurant'] Café 0.2 Chinese Restaurant 0.2 Fish & Chips Shop 0.2 Ice Cream Shop 0.2 Indian Restaurant 0.2 Bakery 0.0 Italian Restaurant 0.0 Turkish Restaurant 0.0 Thai Restaurant 0.0 Steakhouse 0.0 Snack Place 0.0 Seafood Restaurant 0.0 Sandwich Place 0.0 Restaurant 0.0 Pub 0.0 Pizza Place 0.0 Gastropub 0.0 Bar 0.0 Food Truck 0.0 Fast Food Restaurant 0.0 Diner 0.0 Dessert Shop 0.0 Deli / Bodega 0.0 Coffee Shop 0.0 Burger Joint 0.0 Breakfast Spot 0.0 Vietnamese Restaurant 0.0 Name: 1, dtype: object ['Café', 'Chinese Restaurant', 'Fish & Chips Shop'] Bakery 0.181818 Fast Food Restaurant 0.181818 Coffee Shop 0.090909 Snack Place 0.090909 Seafood Restaurant 0.090909 Food Truck 0.090909 Gastropub 0.090909 Café 0.090909 Deli / Bodega 0.0 Pub 0.0 Turkish Restaurant 0.0 Thai Restaurant 0.0 Steakhouse 0.0 Breakfast Spot 0.0 Burger Joint 0.0 Sandwich Place 0.0 Restaurant 0.0 Pizza Place 0.0 Dessert Shop 0.0 Italian Restaurant 0.0 Indian Restaurant 0.0 Ice Cream Shop 0.0 Bar 0.0 Fish & Chips Shop 0.0 Chinese Restaurant 0.0 Diner 0.0 Vietnamese Restaurant 0.0 Name: 2, dtype: object ['Bakery', 'Fast Food Restaurant', 'Coffee Shop'] Gastropub 0.2 Indian Restaurant 0.2 Café 0.2 Chinese Restaurant 0.2 Restaurant 0.2 Turkish Restaurant 0.0 Thai Restaurant 0.0 Steakhouse 0.0 Snack Place 0.0 Seafood Restaurant 0.0 Sandwich Place 0.0 Pub 0.0 Pizza Place 0.0 Italian Restaurant 0.0 Bakery 0.0 Ice Cream Shop 0.0 Bar 0.0 Food Truck 0.0 Fish & Chips Shop 0.0 Fast Food Restaurant 0.0 Diner 0.0 Dessert Shop 0.0 Deli / Bodega 0.0 Coffee Shop 0.0 Burger Joint 0.0 Breakfast Spot 0.0 Vietnamese Restaurant 0.0 Name: 3, dtype: object ['Gastropub', 'Indian Restaurant', 'Café'] Indian Restaurant 0.4 Café 0.2 Chinese Restaurant 0.2 Pizza Place 0.1 Italian Restaurant 0.1 Bakery 0.0 Turkish Restaurant 0.0 Thai Restaurant 0.0 Steakhouse 0.0 Snack Place 0.0 Seafood Restaurant 0.0 Sandwich Place 0.0 Restaurant 0.0 Pub 0.0 Gastropub 0.0 Ice Cream Shop 0.0 Bar 0.0 Food Truck 0.0 Fish & Chips Shop 0.0 Fast Food Restaurant 0.0 Diner 0.0 Dessert Shop 0.0 Deli / Bodega 0.0 Coffee Shop 0.0 Burger Joint 0.0 Breakfast Spot 0.0 Vietnamese Restaurant 0.0 Name: 4, dtype: object ['Indian Restaurant', 'Café', 'Chinese Restaurant'] Chinese Restaurant 0.25 Bakery 0.125 Café 0.125 Coffee Shop 0.125 Vietnamese Restaurant 0.125 Breakfast Spot 0.125 Burger Joint 0.0 Turkish Restaurant 0.0 Thai Restaurant 0.0 Steakhouse 0.0 Snack Place 0.0 Seafood Restaurant 0.0 Sandwich Place 0.0 Restaurant 0.0 Pub 0.0 Pizza Place 0.0 Italian Restaurant 0.0 Indian Restaurant 0.0 Ice Cream Shop 0.0 Bar 0.0 Food Truck 0.0 Fish & Chips Shop 0.0 Fast Food Restaurant 0.0 Diner 0.0 Dessert Shop 0.0 Deli / Bodega 0.0 Gastropub 0.0 Name: 5, dtype: object ['Chinese Restaurant', 'Bakery', 'Café'] Coffee Shop 0.222222 Sandwich Place 0.222222 Café 0.111111 Dessert Shop 0.111111 Fish & Chips Shop 0.111111 Pizza Place 0.111111 Bakery 0.0 Italian Restaurant 0.0 Turkish Restaurant 0.0 Thai Restaurant 0.0 Steakhouse 0.0 Snack Place 0.0 Seafood Restaurant 0.0 Restaurant 0.0 Pub 0.0 Gastropub 0.0 Indian Restaurant 0.0 Ice Cream Shop 0.0 Bar 0.0 Food Truck 0.0 Fast Food Restaurant 0.0 Diner 0.0 Deli / Bodega 0.0 Chinese Restaurant 0.0 Burger Joint 0.0 Breakfast Spot 0.0 Vietnamese Restaurant 0.0 Name: 6, dtype: object ['Coffee Shop', 'Sandwich Place', 'Café'] Gastropub 0.2 Coffee Shop 0.2 Diner 0.2 Fast Food Restaurant 0.2 Restaurant 0.2 Indian Restaurant 0.0 Turkish Restaurant 0.0 Thai Restaurant 0.0 Steakhouse 0.0 Snack Place 0.0 Seafood Restaurant 0.0 Sandwich Place 0.0 Pub 0.0 Pizza Place 0.0 Italian Restaurant 0.0 Bakery 0.0 Ice Cream Shop 0.0 Bar 0.0 Food Truck 0.0 Fish & Chips Shop 0.0 Dessert Shop 0.0 Deli / Bodega 0.0 Chinese Restaurant 0.0 Café 0.0 Burger Joint 0.0 Breakfast Spot 0.0 Vietnamese Restaurant 0.0 Name: 7, dtype: object ['Gastropub', 'Coffee Shop', 'Diner'] Coffee Shop 0.230769 Italian Restaurant 0.153846 Gastropub 0.076923 Burger Joint 0.076923 Thai Restaurant 0.076923 Chinese Restaurant 0.076923 Steakhouse 0.076923 Indian Restaurant 0.0 Turkish Restaurant 0.0 Snack Place 0.0 Seafood Restaurant 0.0 Sandwich Place 0.0 Restaurant 0.0 Pub 0.0 Pizza Place 0.0 Bakery 0.0 Ice Cream Shop 0.0 Bar 0.0 Food Truck 0.0 Fish & Chips Shop 0.0 Fast Food Restaurant 0.0 Diner 0.0 Dessert Shop 0.0 Deli / Bodega 0.0 Café 0.0 Breakfast Spot 0.0 Vietnamese Restaurant 0.0 Name: 8, dtype: object ['Coffee Shop', 'Italian Restaurant', 'Gastropub'] Coffee Shop 0.25 Fast Food Restaurant 0.25 Bakery 0.125 Café 0.125 Sandwich Place 0.125 Indian Restaurant 0.0 Turkish Restaurant 0.0 Thai Restaurant 0.0 Steakhouse 0.0 Snack Place 0.0 Seafood Restaurant 0.0 Restaurant 0.0 Pub 0.0 Pizza Place 0.0 Italian Restaurant 0.0 Gastropub 0.0 Ice Cream Shop 0.0 Bar 0.0 Food Truck 0.0 Fish & Chips Shop 0.0 Diner 0.0 Dessert Shop 0.0 Deli / Bodega 0.0 Chinese Restaurant 0.0 Burger Joint 0.0 Breakfast Spot 0.0 Vietnamese Restaurant 0.0 Name: 9, dtype: object ['Coffee Shop', 'Fast Food Restaurant', 'Bakery'] Coffee Shop 0.357143 Ice Cream Shop 0.142857 Bakery 0.071429 Steakhouse 0.071429 Indian Restaurant 0.071429 Gastropub 0.071429 Breakfast Spot 0.071429 Café 0.071429 Chinese Restaurant 0.0 Pizza Place 0.0 Turkish Restaurant 0.0 Thai Restaurant 0.0 Snack Place 0.0 Seafood Restaurant 0.0 Sandwich Place 0.0 Restaurant 0.0 Pub 0.0 Italian Restaurant 0.0 Deli / Bodega 0.0 Burger Joint 0.0 Bar 0.0 Food Truck 0.0 Fish & Chips Shop 0.0 Fast Food Restaurant 0.0 Diner 0.0 Dessert Shop 0.0 Vietnamese Restaurant 0.0 Name: 10, dtype: object ['Coffee Shop', 'Ice Cream Shop', 'Bakery'] Café 0.2 Coffee Shop 0.2 Chinese Restaurant 0.133333 Bakery 0.066667 Dessert Shop 0.066667 Italian Restaurant 0.066667 Indian Restaurant 0.066667 Gastropub 0.066667 Breakfast Spot 0.066667 Deli / Bodega 0.0 Pub 0.0 Turkish Restaurant 0.0 Thai Restaurant 0.0 Steakhouse 0.0 Snack Place 0.0 Seafood Restaurant 0.0 Sandwich Place 0.0 Restaurant 0.0 Pizza Place 0.0 Diner 0.0 Burger Joint 0.0 Ice Cream Shop 0.0 Bar 0.0 Food Truck 0.0 Fish & Chips Shop 0.0 Fast Food Restaurant 0.0 Vietnamese Restaurant 0.0 Name: 11, dtype: object ['Café', 'Coffee Shop', 'Chinese Restaurant'] Chinese Restaurant 0.272727 Café 0.181818 Bakery 0.090909 Breakfast Spot 0.090909 Burger Joint 0.090909 Coffee Shop 0.090909 Fast Food Restaurant 0.090909 Pizza Place 0.0 Turkish Restaurant 0.0 Thai Restaurant 0.0 Steakhouse 0.0 Snack Place 0.0 Seafood Restaurant 0.0 Sandwich Place 0.0 Restaurant 0.0 Pub 0.0 Gastropub 0.0 Italian Restaurant 0.0 Indian Restaurant 0.0 Ice Cream Shop 0.0 Bar 0.0 Food Truck 0.0 Fish & Chips Shop 0.0 Diner 0.0 Dessert Shop 0.0 Deli / Bodega 0.0 Vietnamese Restaurant 0.0 Name: 12, dtype: object ['Chinese Restaurant', 'Café', 'Bakery'] Coffee Shop 0.333333 Bakery 0.166667 Snack Place 0.166667 Pizza Place 0.166667 Italian Restaurant 0.166667 Ice Cream Shop 0.0 Turkish Restaurant 0.0 Thai Restaurant 0.0 Steakhouse 0.0 Seafood Restaurant 0.0 Sandwich Place 0.0 Restaurant 0.0 Pub 0.0 Indian Restaurant 0.0 Gastropub 0.0 Bar 0.0 Food Truck 0.0 Fish & Chips Shop 0.0 Fast Food Restaurant 0.0 Diner 0.0 Dessert Shop 0.0 Deli / Bodega 0.0 Chinese Restaurant 0.0 Café 0.0 Burger Joint 0.0 Breakfast Spot 0.0 Vietnamese Restaurant 0.0 Name: 13, dtype: object ['Coffee Shop', 'Bakery', 'Snack Place'] Bakery 0.333333 Café 0.166667 Pizza Place 0.166667 Bar 0.166667 Gastropub 0.166667 Chinese Restaurant 0.0 Coffee Shop 0.0 Turkish Restaurant 0.0 Thai Restaurant 0.0 Steakhouse 0.0 Snack Place 0.0 Seafood Restaurant 0.0 Sandwich Place 0.0 Restaurant 0.0 Pub 0.0 Breakfast Spot 0.0 Italian Restaurant 0.0 Indian Restaurant 0.0 Ice Cream Shop 0.0 Burger Joint 0.0 Food Truck 0.0 Fish & Chips Shop 0.0 Fast Food Restaurant 0.0 Diner 0.0 Dessert Shop 0.0 Deli / Bodega 0.0 Vietnamese Restaurant 0.0 Name: 14, dtype: object ['Bakery', 'Café', 'Pizza Place'] Indian Restaurant 0.173913 Chinese Restaurant 0.130435 Bakery 0.086957 Fast Food Restaurant 0.086957 Pizza Place 0.086957 Café 0.086957 Pub 0.043478 Italian Restaurant 0.043478 Fish & Chips Shop 0.043478 Gastropub 0.043478 Deli / Bodega 0.043478 Coffee Shop 0.043478 Diner 0.0 Sandwich Place 0.0 Turkish Restaurant 0.0 Thai Restaurant 0.0 Steakhouse 0.0 Snack Place 0.0 Seafood Restaurant 0.0 Breakfast Spot 0.0 Restaurant 0.0 Dessert Shop 0.0 Burger Joint 0.0 Ice Cream Shop 0.0 Bar 0.0 Food Truck 0.0 Vietnamese Restaurant 0.0 Name: 15, dtype: object ['Indian Restaurant', 'Chinese Restaurant', 'Bakery'] Café 0.285714 Coffee Shop 0.285714 Fast Food Restaurant 0.285714 Indian Restaurant 0.142857 Bakery 0.0 Turkish Restaurant 0.0 Thai Restaurant 0.0 Steakhouse 0.0 Snack Place 0.0 Seafood Restaurant 0.0 Sandwich Place 0.0 Restaurant 0.0 Pub 0.0 Pizza Place 0.0 Italian Restaurant 0.0 Gastropub 0.0 Ice Cream Shop 0.0 Bar 0.0 Food Truck 0.0 Fish & Chips Shop 0.0 Diner 0.0 Dessert Shop 0.0 Deli / Bodega 0.0 Chinese Restaurant 0.0 Burger Joint 0.0 Breakfast Spot 0.0 Vietnamese Restaurant 0.0 Name: 16, dtype: object ['Café', 'Coffee Shop', 'Fast Food Restaurant'] Fast Food Restaurant 0.5 Café 0.333333 Bakery 0.166667 Indian Restaurant 0.0 Turkish Restaurant 0.0 Thai Restaurant 0.0 Steakhouse 0.0 Snack Place 0.0 Seafood Restaurant 0.0 Sandwich Place 0.0 Restaurant 0.0 Pub 0.0 Pizza Place 0.0 Italian Restaurant 0.0 Gastropub 0.0 Ice Cream Shop 0.0 Bar 0.0 Food Truck 0.0 Fish & Chips Shop 0.0 Diner 0.0 Dessert Shop 0.0 Deli / Bodega 0.0 Coffee Shop 0.0 Chinese Restaurant 0.0 Burger Joint 0.0 Breakfast Spot 0.0 Vietnamese Restaurant 0.0 Name: 17, dtype: object ['Fast Food Restaurant', 'Café', 'Bakery'] Café 0.5 Chinese Restaurant 0.25 Bakery 0.125 Fish & Chips Shop 0.125 Indian Restaurant 0.0 Turkish Restaurant 0.0 Thai Restaurant 0.0 Steakhouse 0.0 Snack Place 0.0 Seafood Restaurant 0.0 Sandwich Place 0.0 Restaurant 0.0 Pub 0.0 Pizza Place 0.0 Italian Restaurant 0.0 Gastropub 0.0 Ice Cream Shop 0.0 Bar 0.0 Food Truck 0.0 Fast Food Restaurant 0.0 Diner 0.0 Dessert Shop 0.0 Deli / Bodega 0.0 Coffee Shop 0.0 Burger Joint 0.0 Breakfast Spot 0.0 Vietnamese Restaurant 0.0 Name: 18, dtype: object ['Café', 'Chinese Restaurant', 'Bakery'] Bakery 0.166667 Indian Restaurant 0.166667 Café 0.166667 Coffee Shop 0.166667 Restaurant 0.166667 Turkish Restaurant 0.0 Thai Restaurant 0.0 Steakhouse 0.0 Snack Place 0.0 Seafood Restaurant 0.0 Sandwich Place 0.0 Pub 0.0 Pizza Place 0.0 Italian Restaurant 0.0 Gastropub 0.0 Ice Cream Shop 0.0 Bar 0.0 Food Truck 0.0 Fish & Chips Shop 0.0 Fast Food Restaurant 0.0 Diner 0.0 Dessert Shop 0.0 Deli / Bodega 0.0 Chinese Restaurant 0.0 Burger Joint 0.0 Breakfast Spot 0.0 Vietnamese Restaurant 0.0 Name: 19, dtype: object ['Bakery', 'Indian Restaurant', 'Café'] Café 0.384615 Coffee Shop 0.153846 Indian Restaurant 0.153846 Bakery 0.076923 Chinese Restaurant 0.076923 Fish & Chips Shop 0.076923 Italian Restaurant 0.0 Turkish Restaurant 0.0 Thai Restaurant 0.0 Steakhouse 0.0 Snack Place 0.0 Seafood Restaurant 0.0 Sandwich Place 0.0 Restaurant 0.0 Pub 0.0 Pizza Place 0.0 Gastropub 0.0 Ice Cream Shop 0.0 Bar 0.0 Food Truck 0.0 Fast Food Restaurant 0.0 Diner 0.0 Dessert Shop 0.0 Deli / Bodega 0.0 Burger Joint 0.0 Breakfast Spot 0.0 Vietnamese Restaurant 0.0 Name: 20, dtype: object ['Café', 'Coffee Shop', 'Indian Restaurant'] Bakery 0.2 Chinese Restaurant 0.2 Fish & Chips Shop 0.2 Pizza Place 0.2 Indian Restaurant 0.0 Turkish Restaurant 0.0 Thai Restaurant 0.0 Steakhouse 0.0 Snack Place 0.0 Seafood Restaurant 0.0 Sandwich Place 0.0 Restaurant 0.0 Pub 0.0 Italian Restaurant 0.0 Gastropub 0.0 Ice Cream Shop 0.0 Bar 0.0 Food Truck 0.0 Fast Food Restaurant 0.0 Diner 0.0 Dessert Shop 0.0 Deli / Bodega 0.0 Coffee Shop 0.0 Café 0.0 Burger Joint 0.0 Breakfast Spot 0.0 Vietnamese Restaurant 0.0 Name: 21, dtype: object ['Bakery', 'Chinese Restaurant', 'Fish & Chips Shop'] Chinese Restaurant 0.266667 Italian Restaurant 0.2 Pizza Place 0.2 Coffee Shop 0.066667 Deli / Bodega 0.066667 Fish & Chips Shop 0.066667 Pub 0.066667 Bakery 0.0 Turkish Restaurant 0.0 Thai Restaurant 0.0 Steakhouse 0.0 Snack Place 0.0 Seafood Restaurant 0.0 Sandwich Place 0.0 Restaurant 0.0 Gastropub 0.0 Indian Restaurant 0.0 Ice Cream Shop 0.0 Bar 0.0 Food Truck 0.0 Fast Food Restaurant 0.0 Diner 0.0 Dessert Shop 0.0 Café 0.0 Burger Joint 0.0 Breakfast Spot 0.0 Vietnamese Restaurant 0.0 Name: 22, dtype: object ['Chinese Restaurant', 'Italian Restaurant', 'Pizza Place'] Bar 0.153846 Café 0.153846 Bakery 0.076923 Deli / Bodega 0.076923 Indian Restaurant 0.076923 Seafood Restaurant 0.076923 Diner 0.076923 Italian Restaurant 0.076923 Coffee Shop 0.076923 Steakhouse 0.076923 Turkish Restaurant 0.076923 Pizza Place 0.0 Sandwich Place 0.0 Restaurant 0.0 Thai Restaurant 0.0 Pub 0.0 Snack Place 0.0 Gastropub 0.0 Ice Cream Shop 0.0 Food Truck 0.0 Fish & Chips Shop 0.0 Fast Food Restaurant 0.0 Dessert Shop 0.0 Chinese Restaurant 0.0 Burger Joint 0.0 Breakfast Spot 0.0 Vietnamese Restaurant 0.0 Name: 23, dtype: object ['Bar', 'Café', 'Bakery'] Café 0.375 Breakfast Spot 0.125 Chinese Restaurant 0.125 Coffee Shop 0.125 Pizza Place 0.125 Indian Restaurant 0.125 Bakery 0.0 Italian Restaurant 0.0 Turkish Restaurant 0.0 Thai Restaurant 0.0 Steakhouse 0.0 Snack Place 0.0 Seafood Restaurant 0.0 Sandwich Place 0.0 Restaurant 0.0 Pub 0.0 Gastropub 0.0 Ice Cream Shop 0.0 Bar 0.0 Food Truck 0.0 Fish & Chips Shop 0.0 Fast Food Restaurant 0.0 Diner 0.0 Dessert Shop 0.0 Deli / Bodega 0.0 Burger Joint 0.0 Vietnamese Restaurant 0.0 Name: 24, dtype: object ['Café', 'Breakfast Spot', 'Chinese Restaurant'] Restaurant 0.133333 Café 0.133333 Chinese Restaurant 0.133333 Fish & Chips Shop 0.133333 Bakery 0.066667 Fast Food Restaurant 0.066667 Indian Restaurant 0.066667 Dessert Shop 0.066667 Coffee Shop 0.066667 Thai Restaurant 0.066667 Pizza Place 0.0 Snack Place 0.0 Steakhouse 0.0 Seafood Restaurant 0.0 Sandwich Place 0.0 Turkish Restaurant 0.0 Pub 0.0 Gastropub 0.0 Italian Restaurant 0.0 Ice Cream Shop 0.0 Bar 0.0 Food Truck 0.0 Diner 0.0 Deli / Bodega 0.0 Burger Joint 0.0 Breakfast Spot 0.0 Vietnamese Restaurant 0.0 Name: 25, dtype: object ['Restaurant', 'Café', 'Chinese Restaurant'] Bakery 0.2 Indian Restaurant 0.2 Steakhouse 0.2 Chinese Restaurant 0.2 Fast Food Restaurant 0.2 Turkish Restaurant 0.0 Thai Restaurant 0.0 Snack Place 0.0 Seafood Restaurant 0.0 Sandwich Place 0.0 Restaurant 0.0 Pub 0.0 Pizza Place 0.0 Italian Restaurant 0.0 Gastropub 0.0 Ice Cream Shop 0.0 Bar 0.0 Food Truck 0.0 Fish & Chips Shop 0.0 Diner 0.0 Dessert Shop 0.0 Deli / Bodega 0.0 Coffee Shop 0.0 Café 0.0 Burger Joint 0.0 Breakfast Spot 0.0 Vietnamese Restaurant 0.0 Name: 26, dtype: object ['Bakery', 'Indian Restaurant', 'Steakhouse'] Chinese Restaurant 0.333333 Bakery 0.166667 Indian Restaurant 0.166667 Café 0.166667 Fish & Chips Shop 0.166667 Turkish Restaurant 0.0 Thai Restaurant 0.0 Steakhouse 0.0 Snack Place 0.0 Seafood Restaurant 0.0 Sandwich Place 0.0 Restaurant 0.0 Pub 0.0 Pizza Place 0.0 Italian Restaurant 0.0 Gastropub 0.0 Ice Cream Shop 0.0 Bar 0.0 Food Truck 0.0 Fast Food Restaurant 0.0 Diner 0.0 Dessert Shop 0.0 Deli / Bodega 0.0 Coffee Shop 0.0 Burger Joint 0.0 Breakfast Spot 0.0 Vietnamese Restaurant 0.0 Name: 27, dtype: object ['Chinese Restaurant', 'Bakery', 'Indian Restaurant'] Chinese Restaurant 0.285714 Café 0.142857 Coffee Shop 0.142857 Fish & Chips Shop 0.142857 Restaurant 0.142857 Pizza Place 0.142857 Bakery 0.0 Italian Restaurant 0.0 Turkish Restaurant 0.0 Thai Restaurant 0.0 Steakhouse 0.0 Snack Place 0.0 Seafood Restaurant 0.0 Sandwich Place 0.0 Pub 0.0 Gastropub 0.0 Indian Restaurant 0.0 Ice Cream Shop 0.0 Bar 0.0 Food Truck 0.0 Fast Food Restaurant 0.0 Diner 0.0 Dessert Shop 0.0 Deli / Bodega 0.0 Burger Joint 0.0 Breakfast Spot 0.0 Vietnamese Restaurant 0.0 Name: 28, dtype: object ['Chinese Restaurant', 'Café', 'Coffee Shop'] Café 0.190476 Bakery 0.095238 Restaurant 0.095238 Indian Restaurant 0.095238 Vietnamese Restaurant 0.095238 Chinese Restaurant 0.047619 Coffee Shop 0.047619 Breakfast Spot 0.047619 Pub 0.047619 Italian Restaurant 0.047619 Fast Food Restaurant 0.0 Deli / Bodega 0.0 Turkish Restaurant 0.0 Thai Restaurant 0.0 Steakhouse 0.0 Snack Place 0.0 Seafood Restaurant 0.0 Sandwich Place 0.0 Dessert Shop 0.0 Fish & Chips Shop 0.0 Pizza Place 0.0 Diner 0.0 Burger Joint 0.0 Ice Cream Shop 0.0 Bar 0.0 Food Truck 0.0 Gastropub 0.0 Name: 29, dtype: object ['Café', 'Bakery', 'Restaurant'] Coffee Shop 0.214286 Café 0.142857 Bakery 0.071429 Turkish Restaurant 0.071429 Chinese Restaurant 0.071429 Deli / Bodega 0.071429 Sandwich Place 0.071429 Bar 0.071429 Pub 0.071429 Italian Restaurant 0.0 Thai Restaurant 0.0 Steakhouse 0.0 Snack Place 0.0 Seafood Restaurant 0.0 Restaurant 0.0 Pizza Place 0.0 Gastropub 0.0 Indian Restaurant 0.0 Ice Cream Shop 0.0 Food Truck 0.0 Fish & Chips Shop 0.0 Fast Food Restaurant 0.0 Diner 0.0 Dessert Shop 0.0 Burger Joint 0.0 Breakfast Spot 0.0 Vietnamese Restaurant 0.0 Name: 30, dtype: object ['Coffee Shop', 'Café', 'Bakery'] Café 0.285714 Bakery 0.142857 Breakfast Spot 0.142857 Chinese Restaurant 0.142857 Coffee Shop 0.142857 Indian Restaurant 0.142857 Italian Restaurant 0.0 Turkish Restaurant 0.0 Thai Restaurant 0.0 Steakhouse 0.0 Snack Place 0.0 Seafood Restaurant 0.0 Sandwich Place 0.0 Restaurant 0.0 Pub 0.0 Pizza Place 0.0 Gastropub 0.0 Ice Cream Shop 0.0 Bar 0.0 Food Truck 0.0 Fish & Chips Shop 0.0 Fast Food Restaurant 0.0 Diner 0.0 Dessert Shop 0.0 Deli / Bodega 0.0 Burger Joint 0.0 Vietnamese Restaurant 0.0 Name: 31, dtype: object ['Café', 'Bakery', 'Breakfast Spot'] Café 0.4 Coffee Shop 0.2 Restaurant 0.2 Pub 0.2 Bakery 0.0 Indian Restaurant 0.0 Turkish Restaurant 0.0 Thai Restaurant 0.0 Steakhouse 0.0 Snack Place 0.0 Seafood Restaurant 0.0 Sandwich Place 0.0 Pizza Place 0.0 Italian Restaurant 0.0 Gastropub 0.0 Ice Cream Shop 0.0 Bar 0.0 Food Truck 0.0 Fish & Chips Shop 0.0 Fast Food Restaurant 0.0 Diner 0.0 Dessert Shop 0.0 Deli / Bodega 0.0 Chinese Restaurant 0.0 Burger Joint 0.0 Breakfast Spot 0.0 Vietnamese Restaurant 0.0 Name: 32, dtype: object ['Café', 'Coffee Shop', 'Restaurant'] Café 0.2 Chinese Restaurant 0.2 Snack Place 0.2 Fast Food Restaurant 0.2 Restaurant 0.2 Bakery 0.0 Indian Restaurant 0.0 Turkish Restaurant 0.0 Thai Restaurant 0.0 Steakhouse 0.0 Seafood Restaurant 0.0 Sandwich Place 0.0 Pub 0.0 Pizza Place 0.0 Italian Restaurant 0.0 Gastropub 0.0 Ice Cream Shop 0.0 Bar 0.0 Food Truck 0.0 Fish & Chips Shop 0.0 Diner 0.0 Dessert Shop 0.0 Deli / Bodega 0.0 Coffee Shop 0.0 Burger Joint 0.0 Breakfast Spot 0.0 Vietnamese Restaurant 0.0 Name: 33, dtype: object ['Café', 'Chinese Restaurant', 'Snack Place'] Café 0.285714 Steakhouse 0.142857 Sandwich Place 0.142857 Pizza Place 0.142857 Bakery 0.0 Ice Cream Shop 0.0 Turkish Restaurant 0.0 Thai Restaurant 0.0 Snack Place 0.0 Seafood Restaurant 0.0 Restaurant 0.0 Pub 0.0 Italian Restaurant 0.0 Indian Restaurant 0.0 Gastropub 0.0 Bar 0.0 Food Truck 0.0 Fish & Chips Shop 0.0 Fast Food Restaurant 0.0 Diner 0.0 Dessert Shop 0.0 Deli / Bodega 0.0 Coffee Shop 0.0 Chinese Restaurant 0.0 Burger Joint 0.0 Breakfast Spot 0.0 Vietnamese Restaurant 0.0 Name: 34, dtype: object ['Café', 'Steakhouse', 'Sandwich Place'] Bakery 0.111111 Indian Restaurant 0.111111 Turkish Restaurant 0.111111 Café 0.111111 Chinese Restaurant 0.111111 Restaurant 0.111111 Pizza Place 0.111111 Thai Restaurant 0.0 Steakhouse 0.0 Snack Place 0.0 Seafood Restaurant 0.0 Sandwich Place 0.0 Pub 0.0 Italian Restaurant 0.0 Gastropub 0.0 Ice Cream Shop 0.0 Bar 0.0 Food Truck 0.0 Fish & Chips Shop 0.0 Fast Food Restaurant 0.0 Diner 0.0 Dessert Shop 0.0 Deli / Bodega 0.0 Coffee Shop 0.0 Burger Joint 0.0 Breakfast Spot 0.0 Vietnamese Restaurant 0.0 Name: 35, dtype: object ['Bakery', 'Indian Restaurant', 'Turkish Restaurant'] Coffee Shop 0.6 Café 0.4 Bakery 0.0 Indian Restaurant 0.0 Turkish Restaurant 0.0 Thai Restaurant 0.0 Steakhouse 0.0 Snack Place 0.0 Seafood Restaurant 0.0 Sandwich Place 0.0 Restaurant 0.0 Pub 0.0 Pizza Place 0.0 Italian Restaurant 0.0 Gastropub 0.0 Ice Cream Shop 0.0 Bar 0.0 Food Truck 0.0 Fish & Chips Shop 0.0 Fast Food Restaurant 0.0 Diner 0.0 Dessert Shop 0.0 Deli / Bodega 0.0 Chinese Restaurant 0.0 Burger Joint 0.0 Breakfast Spot 0.0 Vietnamese Restaurant 0.0 Name: 36, dtype: object ['Coffee Shop', 'Café', '....'] Café 0.5 Coffee Shop 0.375 Bakery 0.0 Indian Restaurant 0.0 Turkish Restaurant 0.0 Thai Restaurant 0.0 Steakhouse 0.0 Snack Place 0.0 Seafood Restaurant 0.0 Sandwich Place 0.0 Restaurant 0.0 Pub 0.0 Pizza Place 0.0 Italian Restaurant 0.0 Gastropub 0.0 Ice Cream Shop 0.0 Bar 0.0 Food Truck 0.0 Fish & Chips Shop 0.0 Fast Food Restaurant 0.0 Diner 0.0 Dessert Shop 0.0 Deli / Bodega 0.0 Chinese Restaurant 0.0 Burger Joint 0.0 Breakfast Spot 0.0 Vietnamese Restaurant 0.0 Name: 37, dtype: object ['Café', 'Coffee Shop', '....'] Restaurant 0.4 Breakfast Spot 0.2 Steakhouse 0.2 Coffee Shop 0.2 Bakery 0.0 Indian Restaurant 0.0 Turkish Restaurant 0.0 Thai Restaurant 0.0 Snack Place 0.0 Seafood Restaurant 0.0 Sandwich Place 0.0 Pub 0.0 Pizza Place 0.0 Italian Restaurant 0.0 Gastropub 0.0 Ice Cream Shop 0.0 Bar 0.0 Food Truck 0.0 Fish & Chips Shop 0.0 Fast Food Restaurant 0.0 Diner 0.0 Dessert Shop 0.0 Deli / Bodega 0.0 Chinese Restaurant 0.0 Café 0.0 Burger Joint 0.0 Vietnamese Restaurant 0.0 Name: 38, dtype: object ['Restaurant', 'Breakfast Spot', 'Steakhouse'] Café 0.2 Fast Food Restaurant 0.2 Chinese Restaurant 0.133333 Indian Restaurant 0.133333 Breakfast Spot 0.066667 Coffee Shop 0.066667 Snack Place 0.066667 Bakery 0.0 Pizza Place 0.0 Turkish Restaurant 0.0 Thai Restaurant 0.0 Steakhouse 0.0 Seafood Restaurant 0.0 Sandwich Place 0.0 Restaurant 0.0 Pub 0.0 Gastropub 0.0 Italian Restaurant 0.0 Ice Cream Shop 0.0 Bar 0.0 Food Truck 0.0 Fish & Chips Shop 0.0 Diner 0.0 Dessert Shop 0.0 Deli / Bodega 0.0 Burger Joint 0.0 Vietnamese Restaurant 0.0 Name: 39, dtype: object ['Café', 'Fast Food Restaurant', 'Chinese Restaurant'] Café 0.384615 Chinese Restaurant 0.153846 Coffee Shop 0.153846 Bakery 0.076923 Pub 0.076923 Pizza Place 0.076923 Italian Restaurant 0.076923 Indian Restaurant 0.0 Turkish Restaurant 0.0 Thai Restaurant 0.0 Steakhouse 0.0 Snack Place 0.0 Seafood Restaurant 0.0 Sandwich Place 0.0 Restaurant 0.0 Gastropub 0.0 Ice Cream Shop 0.0 Bar 0.0 Food Truck 0.0 Fish & Chips Shop 0.0 Fast Food Restaurant 0.0 Diner 0.0 Dessert Shop 0.0 Deli / Bodega 0.0 Burger Joint 0.0 Breakfast Spot 0.0 Vietnamese Restaurant 0.0 Name: 40, dtype: object ['Café', 'Chinese Restaurant', 'Coffee Shop'] Bakery 0.2 Turkish Restaurant 0.2 Café 0.2 Restaurant 0.2 Pizza Place 0.2 Ice Cream Shop 0.0 Thai Restaurant 0.0 Steakhouse 0.0 Snack Place 0.0 Seafood Restaurant 0.0 Sandwich Place 0.0 Pub 0.0 Italian Restaurant 0.0 Indian Restaurant 0.0 Gastropub 0.0 Bar 0.0 Food Truck 0.0 Fish & Chips Shop 0.0 Fast Food Restaurant 0.0 Diner 0.0 Dessert Shop 0.0 Deli / Bodega 0.0 Coffee Shop 0.0 Chinese Restaurant 0.0 Burger Joint 0.0 Breakfast Spot 0.0 Vietnamese Restaurant 0.0 Name: 41, dtype: object ['Bakery', 'Turkish Restaurant', 'Café'] Coffee Shop 0.173913 Italian Restaurant 0.130435 Café 0.130435 Fast Food Restaurant 0.130435 Vietnamese Restaurant 0.043478 Thai Restaurant 0.043478 Restaurant 0.043478 Pub 0.043478 Bar 0.043478 Pizza Place 0.043478 Indian Restaurant 0.043478 Turkish Restaurant 0.0 Steakhouse 0.0 Snack Place 0.0 Seafood Restaurant 0.0 Sandwich Place 0.0 Bakery 0.0 Ice Cream Shop 0.0 Food Truck 0.0 Fish & Chips Shop 0.0 Diner 0.0 Dessert Shop 0.0 Deli / Bodega 0.0 Chinese Restaurant 0.0 Burger Joint 0.0 Breakfast Spot 0.0 Gastropub 0.0 Name: 42, dtype: object ['Coffee Shop', 'Italian Restaurant', 'Café'] Bakery 0.333333 Restaurant 0.333333 Sandwich Place 0.166667 Fast Food Restaurant 0.166667 Ice Cream Shop 0.0 Turkish Restaurant 0.0 Thai Restaurant 0.0 Steakhouse 0.0 Snack Place 0.0 Seafood Restaurant 0.0 Pub 0.0 Pizza Place 0.0 Italian Restaurant 0.0 Indian Restaurant 0.0 Gastropub 0.0 Bar 0.0 Food Truck 0.0 Fish & Chips Shop 0.0 Diner 0.0 Dessert Shop 0.0 Deli / Bodega 0.0 Coffee Shop 0.0 Chinese Restaurant 0.0 Café 0.0 Burger Joint 0.0 Breakfast Spot 0.0 Vietnamese Restaurant 0.0 Name: 43, dtype: object ['Bakery', 'Restaurant', 'Sandwich Place'] Restaurant 0.25 Café 0.166667 Bakery 0.083333 Indian Restaurant 0.083333 Chinese Restaurant 0.083333 Seafood Restaurant 0.083333 Fish & Chips Shop 0.083333 Pub 0.083333 Turkish Restaurant 0.0 Thai Restaurant 0.0 Steakhouse 0.0 Snack Place 0.0 Sandwich Place 0.0 Pizza Place 0.0 Italian Restaurant 0.0 Gastropub 0.0 Ice Cream Shop 0.0 Bar 0.0 Food Truck 0.0 Fast Food Restaurant 0.0 Diner 0.0 Dessert Shop 0.0 Deli / Bodega 0.0 Coffee Shop 0.0 Burger Joint 0.0 Breakfast Spot 0.0 Vietnamese Restaurant 0.0 Name: 44, dtype: object ['Restaurant', 'Café', 'Bakery'] Café 0.333333 Indian Restaurant 0.083333 Chinese Restaurant 0.083333 Restaurant 0.083333 Pub 0.083333 Bar 0.083333 Bakery 0.0 Turkish Restaurant 0.0 Thai Restaurant 0.0 Steakhouse 0.0 Snack Place 0.0 Seafood Restaurant 0.0 Sandwich Place 0.0 Pizza Place 0.0 Italian Restaurant 0.0 Gastropub 0.0 Ice Cream Shop 0.0 Food Truck 0.0 Fish & Chips Shop 0.0 Fast Food Restaurant 0.0 Diner 0.0 Dessert Shop 0.0 Deli / Bodega 0.0 Coffee Shop 0.0 Burger Joint 0.0 Breakfast Spot 0.0 Vietnamese Restaurant 0.0 Name: 45, dtype: object ['Café', 'Indian Restaurant', 'Chinese Restaurant'] Bar 0.133333 Coffee Shop 0.133333 Gastropub 0.066667 Seafood Restaurant 0.066667 Restaurant 0.066667 Pizza Place 0.066667 Ice Cream Shop 0.066667 Vietnamese Restaurant 0.066667 Burger Joint 0.066667 Dessert Shop 0.0 Pub 0.0 Turkish Restaurant 0.0 Thai Restaurant 0.0 Steakhouse 0.0 Snack Place 0.0 Breakfast Spot 0.0 Sandwich Place 0.0 Café 0.0 Diner 0.0 Italian Restaurant 0.0 Indian Restaurant 0.0 Chinese Restaurant 0.0 Deli / Bodega 0.0 Food Truck 0.0 Fish & Chips Shop 0.0 Fast Food Restaurant 0.0 Bakery 0.0 Name: 46, dtype: object ['Bar', 'Coffee Shop', 'Gastropub'] Fast Food Restaurant 0.4 Chinese Restaurant 0.2 Coffee Shop 0.2 Fish & Chips Shop 0.2 Bakery 0.0 Italian Restaurant 0.0 Turkish Restaurant 0.0 Thai Restaurant 0.0 Steakhouse 0.0 Snack Place 0.0 Seafood Restaurant 0.0 Sandwich Place 0.0 Restaurant 0.0 Pub 0.0 Pizza Place 0.0 Gastropub 0.0 Indian Restaurant 0.0 Ice Cream Shop 0.0 Bar 0.0 Food Truck 0.0 Diner 0.0 Dessert Shop 0.0 Deli / Bodega 0.0 Café 0.0 Burger Joint 0.0 Breakfast Spot 0.0 Vietnamese Restaurant 0.0 Name: 47, dtype: object ['Fast Food Restaurant', 'Chinese Restaurant', 'Coffee Shop'] Chinese Restaurant 0.333333 Indian Restaurant 0.166667 Café 0.166667 Fast Food Restaurant 0.166667 Pizza Place 0.166667 Bakery 0.0 Turkish Restaurant 0.0 Thai Restaurant 0.0 Steakhouse 0.0 Snack Place 0.0 Seafood Restaurant 0.0 Sandwich Place 0.0 Restaurant 0.0 Pub 0.0 Italian Restaurant 0.0 Gastropub 0.0 Ice Cream Shop 0.0 Bar 0.0 Food Truck 0.0 Fish & Chips Shop 0.0 Diner 0.0 Dessert Shop 0.0 Deli / Bodega 0.0 Coffee Shop 0.0 Burger Joint 0.0 Breakfast Spot 0.0 Vietnamese Restaurant 0.0 Name: 48, dtype: object ['Chinese Restaurant', 'Indian Restaurant', 'Café'] Bakery 0.285714 Italian Restaurant 0.285714 Café 0.142857 Coffee Shop 0.142857 Food Truck 0.142857 Indian Restaurant 0.0 Turkish Restaurant 0.0 Thai Restaurant 0.0 Steakhouse 0.0 Snack Place 0.0 Seafood Restaurant 0.0 Sandwich Place 0.0 Restaurant 0.0 Pub 0.0 Pizza Place 0.0 Gastropub 0.0 Ice Cream Shop 0.0 Bar 0.0 Fish & Chips Shop 0.0 Fast Food Restaurant 0.0 Diner 0.0 Dessert Shop 0.0 Deli / Bodega 0.0 Chinese Restaurant 0.0 Burger Joint 0.0 Breakfast Spot 0.0 Vietnamese Restaurant 0.0 Name: 49, dtype: object ['Bakery', 'Italian Restaurant', 'Café'] Café 0.242424 Bakery 0.121212 Chinese Restaurant 0.090909 Fish & Chips Shop 0.060606 Sandwich Place 0.060606 Ice Cream Shop 0.060606 Food Truck 0.060606 Pizza Place 0.060606 Restaurant 0.030303 Fast Food Restaurant 0.030303 Deli / Bodega 0.030303 Bar 0.030303 Indian Restaurant 0.030303 Seafood Restaurant 0.030303 Snack Place 0.0 Steakhouse 0.0 Thai Restaurant 0.0 Turkish Restaurant 0.0 Gastropub 0.0 Pub 0.0 Italian Restaurant 0.0 Diner 0.0 Dessert Shop 0.0 Coffee Shop 0.0 Burger Joint 0.0 Breakfast Spot 0.0 Vietnamese Restaurant 0.0 Name: 50, dtype: object ['Café', 'Bakery', 'Chinese Restaurant'] Gastropub 0.166667 Chinese Restaurant 0.166667 Italian Restaurant 0.166667 Indian Restaurant 0.166667 Ice Cream Shop 0.0 Turkish Restaurant 0.0 Thai Restaurant 0.0 Steakhouse 0.0 Snack Place 0.0 Seafood Restaurant 0.0 Sandwich Place 0.0 Restaurant 0.0 Pub 0.0 Pizza Place 0.0 Bakery 0.0 Bar 0.0 Food Truck 0.0 Fish & Chips Shop 0.0 Fast Food Restaurant 0.0 Diner 0.0 Dessert Shop 0.0 Deli / Bodega 0.0 Coffee Shop 0.0 Café 0.0 Burger Joint 0.0 Breakfast Spot 0.0 Vietnamese Restaurant 0.0 Name: 51, dtype: object ['Gastropub', 'Chinese Restaurant', 'Italian Restaurant'] Coffee Shop 0.444444 Sandwich Place 0.222222 Fast Food Restaurant 0.111111 Bar 0.111111 Bakery 0.0 Indian Restaurant 0.0 Turkish Restaurant 0.0 Thai Restaurant 0.0 Steakhouse 0.0 Snack Place 0.0 Seafood Restaurant 0.0 Restaurant 0.0 Pub 0.0 Pizza Place 0.0 Italian Restaurant 0.0 Gastropub 0.0 Ice Cream Shop 0.0 Food Truck 0.0 Fish & Chips Shop 0.0 Diner 0.0 Dessert Shop 0.0 Deli / Bodega 0.0 Chinese Restaurant 0.0 Café 0.0 Burger Joint 0.0 Breakfast Spot 0.0 Vietnamese Restaurant 0.0 Name: 52, dtype: object ['Coffee Shop', 'Sandwich Place', 'Fast Food Restaurant'] Café 0.6 Diner 0.2 Fast Food Restaurant 0.2 Bakery 0.0 Indian Restaurant 0.0 Turkish Restaurant 0.0 Thai Restaurant 0.0 Steakhouse 0.0 Snack Place 0.0 Seafood Restaurant 0.0 Sandwich Place 0.0 Restaurant 0.0 Pub 0.0 Pizza Place 0.0 Italian Restaurant 0.0 Gastropub 0.0 Ice Cream Shop 0.0 Bar 0.0 Food Truck 0.0 Fish & Chips Shop 0.0 Dessert Shop 0.0 Deli / Bodega 0.0 Coffee Shop 0.0 Chinese Restaurant 0.0 Burger Joint 0.0 Breakfast Spot 0.0 Vietnamese Restaurant 0.0 Name: 53, dtype: object ['Café', 'Diner', 'Fast Food Restaurant'] Café 0.2 Indian Restaurant 0.2 Bakery 0.1 Chinese Restaurant 0.1 Deli / Bodega 0.1 Fast Food Restaurant 0.1 Fish & Chips Shop 0.1 Sandwich Place 0.1 Pizza Place 0.0 Turkish Restaurant 0.0 Thai Restaurant 0.0 Steakhouse 0.0 Snack Place 0.0 Seafood Restaurant 0.0 Restaurant 0.0 Pub 0.0 Gastropub 0.0 Italian Restaurant 0.0 Ice Cream Shop 0.0 Bar 0.0 Food Truck 0.0 Diner 0.0 Dessert Shop 0.0 Coffee Shop 0.0 Burger Joint 0.0 Breakfast Spot 0.0 Vietnamese Restaurant 0.0 Name: 54, dtype: object ['Café', 'Indian Restaurant', 'Bakery'] Café 0.2 Deli / Bodega 0.2 Sandwich Place 0.2 Italian Restaurant 0.2 Ice Cream Shop 0.2 Bakery 0.0 Indian Restaurant 0.0 Turkish Restaurant 0.0 Thai Restaurant 0.0 Steakhouse 0.0 Snack Place 0.0 Seafood Restaurant 0.0 Restaurant 0.0 Pub 0.0 Pizza Place 0.0 Gastropub 0.0 Bar 0.0 Food Truck 0.0 Fish & Chips Shop 0.0 Fast Food Restaurant 0.0 Diner 0.0 Dessert Shop 0.0 Coffee Shop 0.0 Chinese Restaurant 0.0 Burger Joint 0.0 Breakfast Spot 0.0 Vietnamese Restaurant 0.0 Name: 55, dtype: object ['Café', 'Deli / Bodega', 'Sandwich Place'] Chinese Restaurant 0.333333 Indian Restaurant 0.111111 Thai Restaurant 0.111111 Café 0.111111 Coffee Shop 0.111111 Pizza Place 0.111111 Italian Restaurant 0.111111 Bakery 0.0 Turkish Restaurant 0.0 Steakhouse 0.0 Snack Place 0.0 Seafood Restaurant 0.0 Sandwich Place 0.0 Restaurant 0.0 Pub 0.0 Gastropub 0.0 Ice Cream Shop 0.0 Bar 0.0 Food Truck 0.0 Fish & Chips Shop 0.0 Fast Food Restaurant 0.0 Diner 0.0 Dessert Shop 0.0 Deli / Bodega 0.0 Burger Joint 0.0 Breakfast Spot 0.0 Vietnamese Restaurant 0.0 Name: 56, dtype: object ['Chinese Restaurant', 'Indian Restaurant', 'Thai Restaurant'] Café 0.230769 Sandwich Place 0.230769 Breakfast Spot 0.153846 Coffee Shop 0.153846 Bakery 0.076923 Chinese Restaurant 0.076923 Food Truck 0.076923 Italian Restaurant 0.0 Turkish Restaurant 0.0 Thai Restaurant 0.0 Steakhouse 0.0 Snack Place 0.0 Seafood Restaurant 0.0 Restaurant 0.0 Pub 0.0 Pizza Place 0.0 Gastropub 0.0 Indian Restaurant 0.0 Ice Cream Shop 0.0 Bar 0.0 Fish & Chips Shop 0.0 Fast Food Restaurant 0.0 Diner 0.0 Dessert Shop 0.0 Deli / Bodega 0.0 Burger Joint 0.0 Vietnamese Restaurant 0.0 Name: 57, dtype: object ['Café', 'Sandwich Place', 'Breakfast Spot'] Café 0.363636 Coffee Shop 0.181818 Fast Food Restaurant 0.181818 Diner 0.090909 Restaurant 0.090909 Ice Cream Shop 0.090909 Bakery 0.0 Italian Restaurant 0.0 Turkish Restaurant 0.0 Thai Restaurant 0.0 Steakhouse 0.0 Snack Place 0.0 Seafood Restaurant 0.0 Sandwich Place 0.0 Pub 0.0 Pizza Place 0.0 Gastropub 0.0 Indian Restaurant 0.0 Bar 0.0 Food Truck 0.0 Fish & Chips Shop 0.0 Dessert Shop 0.0 Deli / Bodega 0.0 Chinese Restaurant 0.0 Burger Joint 0.0 Breakfast Spot 0.0 Vietnamese Restaurant 0.0 Name: 58, dtype: object ['Café', 'Coffee Shop', 'Fast Food Restaurant'] Café 0.333333 Coffee Shop 0.333333 Breakfast Spot 0.166667 Bakery 0.0 Indian Restaurant 0.0 Turkish Restaurant 0.0 Thai Restaurant 0.0 Steakhouse 0.0 Snack Place 0.0 Seafood Restaurant 0.0 Sandwich Place 0.0 Restaurant 0.0 Pub 0.0 Pizza Place 0.0 Italian Restaurant 0.0 Gastropub 0.0 Ice Cream Shop 0.0 Bar 0.0 Food Truck 0.0 Fish & Chips Shop 0.0 Fast Food Restaurant 0.0 Diner 0.0 Dessert Shop 0.0 Deli / Bodega 0.0 Chinese Restaurant 0.0 Burger Joint 0.0 Vietnamese Restaurant 0.0 Name: 59, dtype: object ['Café', 'Coffee Shop', 'Breakfast Spot'] Restaurant 0.4 Indian Restaurant 0.4 Bakery 0.0 Ice Cream Shop 0.0 Turkish Restaurant 0.0 Thai Restaurant 0.0 Steakhouse 0.0 Snack Place 0.0 Seafood Restaurant 0.0 Sandwich Place 0.0 Pub 0.0 Pizza Place 0.0 Italian Restaurant 0.0 Gastropub 0.0 Bar 0.0 Food Truck 0.0 Fish & Chips Shop 0.0 Fast Food Restaurant 0.0 Diner 0.0 Dessert Shop 0.0 Deli / Bodega 0.0 Coffee Shop 0.0 Chinese Restaurant 0.0 Café 0.0 Burger Joint 0.0 Breakfast Spot 0.0 Vietnamese Restaurant 0.0 Name: 60, dtype: object ['Restaurant', 'Indian Restaurant', '....'] Café 0.4 Coffee Shop 0.2 Pub 0.2 Bar 0.2 Bakery 0.0 Indian Restaurant 0.0 Turkish Restaurant 0.0 Thai Restaurant 0.0 Steakhouse 0.0 Snack Place 0.0 Seafood Restaurant 0.0 Sandwich Place 0.0 Restaurant 0.0 Pizza Place 0.0 Italian Restaurant 0.0 Gastropub 0.0 Ice Cream Shop 0.0 Food Truck 0.0 Fish & Chips Shop 0.0 Fast Food Restaurant 0.0 Diner 0.0 Dessert Shop 0.0 Deli / Bodega 0.0 Chinese Restaurant 0.0 Burger Joint 0.0 Breakfast Spot 0.0 Vietnamese Restaurant 0.0 Name: 61, dtype: object ['Café', 'Coffee Shop', 'Pub'] Coffee Shop 0.166667 Café 0.133333 Fast Food Restaurant 0.1 Burger Joint 0.1 Italian Restaurant 0.066667 Sandwich Place 0.066667 Pizza Place 0.066667 Restaurant 0.033333 Food Truck 0.033333 Bakery 0.033333 Chinese Restaurant 0.033333 Snack Place 0.0 Seafood Restaurant 0.0 Thai Restaurant 0.0 Turkish Restaurant 0.0 Pub 0.0 Steakhouse 0.0 Gastropub 0.0 Indian Restaurant 0.0 Ice Cream Shop 0.0 Bar 0.0 Fish & Chips Shop 0.0 Diner 0.0 Dessert Shop 0.0 Deli / Bodega 0.0 Breakfast Spot 0.0 Vietnamese Restaurant 0.0 Name: 62, dtype: object ['Coffee Shop', 'Café', 'Fast Food Restaurant'] Coffee Shop 0.272727 Burger Joint 0.090909 Café 0.090909 Sandwich Place 0.090909 Italian Restaurant 0.090909 Bakery 0.0 Indian Restaurant 0.0 Turkish Restaurant 0.0 Thai Restaurant 0.0 Steakhouse 0.0 Snack Place 0.0 Seafood Restaurant 0.0 Restaurant 0.0 Pub 0.0 Pizza Place 0.0 Gastropub 0.0 Ice Cream Shop 0.0 Bar 0.0 Food Truck 0.0 Fish & Chips Shop 0.0 Fast Food Restaurant 0.0 Diner 0.0 Dessert Shop 0.0 Deli / Bodega 0.0 Chinese Restaurant 0.0 Breakfast Spot 0.0 Vietnamese Restaurant 0.0 Name: 63, dtype: object ['Coffee Shop', 'Burger Joint', 'Café'] Café 0.4 Indian Restaurant 0.2 Coffee Shop 0.2 Restaurant 0.2 Bakery 0.0 Turkish Restaurant 0.0 Thai Restaurant 0.0 Steakhouse 0.0 Snack Place 0.0 Seafood Restaurant 0.0 Sandwich Place 0.0 Pub 0.0 Pizza Place 0.0 Italian Restaurant 0.0 Gastropub 0.0 Ice Cream Shop 0.0 Bar 0.0 Food Truck 0.0 Fish & Chips Shop 0.0 Fast Food Restaurant 0.0 Diner 0.0 Dessert Shop 0.0 Deli / Bodega 0.0 Chinese Restaurant 0.0 Burger Joint 0.0 Breakfast Spot 0.0 Vietnamese Restaurant 0.0 Name: 64, dtype: object ['Café', 'Indian Restaurant', 'Coffee Shop'] Restaurant 0.428571 Coffee Shop 0.285714 Steakhouse 0.142857 Bakery 0.0 Ice Cream Shop 0.0 Turkish Restaurant 0.0 Thai Restaurant 0.0 Snack Place 0.0 Seafood Restaurant 0.0 Sandwich Place 0.0 Pub 0.0 Pizza Place 0.0 Italian Restaurant 0.0 Indian Restaurant 0.0 Gastropub 0.0 Bar 0.0 Food Truck 0.0 Fish & Chips Shop 0.0 Fast Food Restaurant 0.0 Diner 0.0 Dessert Shop 0.0 Deli / Bodega 0.0 Chinese Restaurant 0.0 Café 0.0 Burger Joint 0.0 Breakfast Spot 0.0 Vietnamese Restaurant 0.0 Name: 65, dtype: object ['Restaurant', 'Coffee Shop', 'Steakhouse']
| Neighbourhood | 1st Most Common Venue | 2nd Most Common Venue | 3rd Most Common Venue | |
|---|---|---|---|---|
| 0 | Abbeyhill | Chinese Restaurant | Café | Fast Food Restaurant |
| 1 | Balgreen/Saughtonhall | Café | Chinese Restaurant | Fish & Chips Shop |
| 2 | Bankhead | Bakery | Fast Food Restaurant | Coffee Shop |
| 3 | Barnton | Gastropub | Indian Restaurant | Café |
| 4 | Blackhall | Indian Restaurant | Café | Chinese Restaurant |
Perform clustering based on the proportion of venues of each type in each neighbourhood.
# set number of clusters
kclusters = 10
edin_grouped_clustering = edin_grouped
edin_grouped_clustering = edin_grouped.drop(['Neighbourhood', 'price tier'], 1)
# run k-means clustering
kmeans = KMeans(n_clusters=kclusters, random_state=1).fit(edin_grouped_clustering)
# check cluster labels generated for each row in the dataframe
kmeans.labels_[0:10]
/var/folders/5x/2qszld594pgblwbdbl9wmmxh0000gn/T/ipykernel_3294/1830617774.py:5: FutureWarning: In a future version of pandas all arguments of DataFrame.drop except for the argument 'labels' will be keyword-only edin_grouped_clustering = edin_grouped.drop(['Neighbourhood', 'price tier'], 1)
array([9, 5, 3, 6, 5, 9, 8, 3, 8, 3], dtype=int32)
# add clustering labels
neighbourhoods_venues_sorted.insert(0, 'Cluster Labels', kmeans.labels_)
edin_merged = df[['NATURALCOM','lat','lon','geometry']]
# merge edin_grouped with the top 3 venues and price tier dataframes.
edin_merged = edin_merged.join(neighbourhoods_venues_sorted.set_index('Neighbourhood'), on='NATURALCOM')
edin_merged = edin_merged.join(edin_grouped[['Neighbourhood','price tier']].set_index('Neighbourhood'), on='NATURALCOM')
#print(edin_merged.shape)
edin_merged.dropna(axis=0, how='any', thresh=None, subset=None, inplace=True)
edin_merged.head(5) # check the last columns!
| NATURALCOM | lat | lon | geometry | Cluster Labels | 1st Most Common Venue | 2nd Most Common Venue | 3rd Most Common Venue | price tier | |
|---|---|---|---|---|---|---|---|---|---|
| 0 | Brunstane/Gilberstoun | 55.940545 | -3.092460 | POLYGON ((-3.10276 55.94435, -3.10276 55.94435... | 3.0 | Gastropub | Coffee Shop | Diner | 0.400000 |
| 3 | Newbridge | 55.939694 | -3.421174 | POLYGON ((-3.41296 55.95159, -3.41414 55.95153... | 0.0 | Bakery | Restaurant | Sandwich Place | 0.333333 |
| 5 | Muirhouse | 55.976491 | -3.259727 | POLYGON ((-3.26528 55.96935, -3.26462 55.96832... | 0.0 | Bakery | Turkish Restaurant | Café | 0.350000 |
| 6 | Granton/West Pilton | 55.977386 | -3.246877 | POLYGON ((-3.24218 55.97880, -3.24279 55.98026... | 9.0 | Chinese Restaurant | Café | Coffee Shop | 0.285714 |
| 8 | Ratho Station/Ingliston/Gogar | 55.937809 | -3.359178 | POLYGON ((-3.32042 55.94104, -3.32275 55.94160... | 8.0 | Coffee Shop | Sandwich Place | Fast Food Restaurant | 0.277778 |
json = edin_merged[['NATURALCOM','geometry']].to_json() # Convert the geometry data to a geojson format for use with folium.
from folium.features import DivIcon
# create map
map_clusters = folium.Map(location=[55.9533, -3.1883], zoom_start=12, tiles='CartoDB positron')
folium.Choropleth(
geo_data=json,
data=edin_merged,
columns=['NATURALCOM','price tier'], #Here we tell folium to get the county fips and plot new_cases_7days metric for each county
key_on='feature.properties.NATURALCOM', #Here we grab the geometries/county boundaries from the geojson file using the key 'coty_code' which is the same as county fips
fill_color='YlOrRd',
nan_fill_color="White", #Use white color if there is no data available for the county
fill_opacity=0.7,
line_opacity=0.2,
legend_name='Average price', #title of the legend
highlight=True,
line_color='black').add_to(map_clusters)
# set color scheme for the clusters
x = np.arange(kclusters)
ys = [i + x + (i*x)**2 for i in range(kclusters)]
colors_array = cm.tab20(np.linspace(0, 1, len(ys)))
rainbow = [colors.rgb2hex(i) for i in colors_array]
# add markers to the map
for lat, lon, poi, cluster, top1, top2, top3, sim_geo, price in zip(edin_merged['lat'], edin_merged['lon'], edin_merged['NATURALCOM'], edin_merged['Cluster Labels'], edin_merged['1st Most Common Venue'], edin_merged['2nd Most Common Venue'], edin_merged['3rd Most Common Venue'],edin_merged['geometry'], edin_merged['price tier']):
geo_j = gpd.GeoSeries(sim_geo).to_json()
geo_j = folium.GeoJson(data=geo_j)
folium.Popup(poi).add_to(geo_j)
#geo_j.add_to(map_clusters)
popup_text = """{}<br>
Cluster: {}<br>
Top venue categories:<br>
1) {}<br>
2) {}<br>
3) {}"""
popup_text = popup_text.format(poi,int(cluster),top1,top2,top3)
label = folium.Popup(popup_text)
folium.CircleMarker(
[lat, lon],
radius=10,
popup=label,
color=rainbow[int(cluster-1)],
fill=True,
fill_color=rainbow[int(cluster-1)],
fill_opacity=1).add_to(map_clusters)
number = '<div style="font-size: 9pt">{}</div>'
folium.map.Marker(
[lat,lon],
icon=DivIcon(
icon_size=(150,36),
icon_anchor=(4,8),
html=number.format(str(int(cluster))),
)
).add_to(map_clusters)
folium.LayerControl().add_to(map_clusters)
map_clusters